home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / misc / unix / tracker_4_3.lzh / tracker / setup_audio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-13  |  2.5 KB  |  131 lines

  1. /* setup_audio.c 
  2.     vi:se ts=3 sw=3:
  3.  */
  4. /* higher level interface to the raw metal */
  5.  
  6. /* $Id: setup_audio.c,v 4.0 1994/01/11 17:55:28 espie Exp espie $
  7.  * $Log: setup_audio.c,v $
  8.  * Revision 4.0  1994/01/11  17:55:28  espie
  9.  * Use autoinit.
  10.  *
  11.  * Revision 1.7  1994/01/09  17:36:22  Espie
  12.  * Generalized open.c.
  13.  *
  14.  * Revision 1.6  1994/01/08  02:04:21  Espie
  15.  * Suppressed multiple at_end.
  16.  *
  17.  * Revision 1.5  1994/01/06  22:32:42  Espie
  18.  * Use new pref scheme.
  19.  *
  20.  * Revision 1.4  1994/01/05  14:54:09  Espie
  21.  * *** empty log message ***
  22.  *
  23.  * Revision 1.3  1993/12/27  00:45:26  Espie
  24.  * Working.
  25.  *
  26.  * Revision 1.2  1993/12/26  18:54:21  Espie
  27.  * Modified in a more consistent way.
  28.  *
  29.  * Revision 1.1  1993/12/26  00:55:53  Espie
  30.  * Initial revision
  31.  *
  32.  * Revision 3.6  1993/12/04  16:12:50  espie
  33.  * BOOL -> boolean.
  34.  *
  35.  * Revision 3.5  1993/11/17  15:31:16  espie
  36.  * New high-level functions.
  37.  *
  38.  * Revision 3.4  1992/11/27  10:29:00  espie
  39.  * General cleanup
  40.  *
  41.  * Revision 3.3  1992/11/24  10:51:19  espie
  42.  * Added check before closing for the sgi.
  43.  *
  44.  * Revision 3.1  1992/11/20  14:53:32  espie
  45.  * Added finetune.
  46.  *
  47.  * Revision 3.0  1992/11/18  16:08:05  espie
  48.  * New release.
  49.  *
  50.  */
  51.  
  52.  
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <string.h>
  56.  
  57. #include "defs.h"
  58. #include "extern.h"
  59. #include "tags.h"
  60. #include "prefs.h"
  61.  
  62. ID("$Id: setup_audio.c,v 4.0 1994/01/11 17:55:28 espie Exp espie $")
  63.  
  64. LOCAL void init_audio P((void));
  65.  
  66. LOCAL void (*INIT)P((void)) = init_audio;
  67.  
  68. LOCAL boolean opened = FALSE;
  69. LOCAL int ask_freq, real_freq, oversample;
  70. LOCAL boolean stereo;
  71.  
  72.  
  73. LOCAL void init_audio()
  74.    {
  75.    at_end(do_close_audio);
  76.    }
  77.  
  78. /* setup_audio(frequency, stereo, oversample):
  79.  * try to avoid calling open_audio and other things
  80.  * all the time
  81.  */
  82. void setup_audio(f, s, o)
  83. int f;
  84. boolean s;
  85. int o;
  86.    {
  87.    INIT_ONCE;
  88.  
  89.    if (!opened)
  90.       {
  91.       ask_freq = f;
  92.       stereo = s;
  93.       oversample = o;
  94.       real_freq = open_audio(f, s);
  95.       init_player(o, real_freq);
  96.       opened = TRUE;
  97.       }
  98.    else
  99.       {
  100.       int new_freq;
  101.  
  102.       if (s != stereo || f != ask_freq)
  103.          {
  104.          ask_freq = f;
  105.          stereo = s;
  106.          close_audio();
  107.          new_freq = open_audio(f, s);
  108.          }
  109.       else
  110.          new_freq = real_freq;
  111.  
  112.       if (new_freq != real_freq || oversample != o)
  113.          {
  114.          real_freq = new_freq;
  115.          oversample = o;
  116.          init_player(o, real_freq);
  117.          }
  118.       }
  119.    set_synchro(get_pref_scalar(PREF_SYNC));
  120.    }
  121.  
  122. void do_close_audio()
  123.    {
  124.    if (opened)
  125.       {
  126.       close_audio();
  127.       }
  128.    opened = FALSE;
  129.    }
  130.  
  131.